/**
 * Created by dujiaheng on 2016/8/4.
 */


tree = {
    name: '胜利油田分公司',
    children: [
        {
            name: '东胜公司'
        },
        {
            name: '石油开发公司',
            children: [
                {name: '胜科采油管理区'},
                {name: '胜凯采油管理区'},
                {name: '胜发采油管理区'},
            ]
        }
    ]
}


function search(tree, name, callback) {
    if (tree.name == name) {
        callback({
            hasChildren: false,
            value: name
        });
        for (var i = 0; i < tree.children.length; i++) {
            var value = tree.children[i].name;
            callback({
                hasChildren: tree.children[i].children != undefined,
                value: value
            });
        }
        return dom;
    } else if (tree.children != undefined) {
        for (var i = 0; i < tree.children.length; i++) {
            search(tree.children[i], name, callback);
        }
    }
}
var dom = [];
search(tree, '胜利油田分公司', value => dom.push(value));
console.log(dom)